// 运行时配置
// 跑在浏览器端
// 可以在这里写函数、jsx、import 浏览器端依赖等等，注意不要引入 node 依赖
console.info('人生如梦#一樽还酹江月')
import RightContent from '@/components/layout/rightContent'
import { history } from 'umi'

const store = JSON.parse(sessionStorage.getItem('store'))

if (!store || !store.auth.authorized) {
    history.push('/auth')
}

export const dva = {
    config: {
        initialState: store || {},
        onStateChange: (state) => {
            sessionStorage.setItem('store', JSON.stringify(state))
        }
    },
};

export async function getInitialState() {
    const data = {};
    return data;
}

export const layout = ({ initialState }) => {
    return {
        rightContentRender: () => <RightContent />
    }
}